import request from '@/utils/request'

// 添加
export function addCategory(data) {
  return request({
    url: '/category/add',
    method: 'post',
    data: data
  })
}

// 编辑
export function editCategory(data) {
  return request({
    url: '/category/edit',
    method: 'post',
    data: data
  })
}

// ID查询单个数据
export function getCategory(id) {
  return request({
    url: '/category/info',
    method: 'post',
    params: { id }
  })
}

// 删除
export function delCategory(id) {
  return request({
    url: '/category/delete',
    method: 'post',
    params: { id }
  })
}

// 批量删除
export function delListCategory(idList) {
  return request({
    url: '/category/delete/list',
    method: 'post',
    data: idList
  })
}

// 查询分页数据
export function dataCategory(query) {
  return request({
    url: '/category/data',
    method: 'post',
    params: query
  })
}

// 查询全部数据
export function allCategory() {
  return request({
    url: '/category/all',
    method: 'post',
  })
}

// 条件查询列表数据
export function listCategory(data) {
  return request({
    url: '/category/list',
    method: 'post',
    data: data
  })
}

// 根据字段、排序方式、limit条 查询列表数据
export function listLimitCategory(field, sort, limit) {
  return request({
    url: '/category/list/limit',
    method: 'post',
    params: { field, sort, limit }
  })
}

// 根据字段查询列表数据
export function listFieldCategory(field, value) {
  return request({
    url: '/category/list/field',
    method: 'post',
    params: { field, value }
  })
}

// 动态查询单个数据
export function dynamicGetCategory(data) {
  return request({
    url: '/category/info/dynamic',
    method: 'post',
    data: data
  })
}

// 查看详情数据
export function detailsGetCategory(id) {
  return request({
    url: '/category/details',
    method: 'post',
    params: { id }
  })
}

// 全部条数
export function countCategory() {
  return request({
    url: '/category/count',
    method: 'post',
  })
}

// 条件查询条数
export function dynamicCountCategory(data) {
  return request({
    url: '/category/count/dynamic',
    method: 'post',
    data: data
  })
}

export function statisticsSalesVolume() {
  return request({
    url: '/category/statistics/salesVolume',
    method: 'post',
  })
}
